amrio.fn.extend({
	fadeIn: function (delay, callback) {
		var _fade = function(delay, degree){
			var ren = this;
			if(degree === 1){
				ren.style.display === "none" ? $(ren).show() : degree = 10;
			}
			if(degree <= 10){
				ren.style.opacity = degree++ * 0.1;
				window.setTimeout(function(){		
					_fade.call(ren, delay, degree);
				},delay);
			}else{
				$.isFunc(callback) && callback.call(ren);
			}
		}
		
		$.isFunc(delay) && (callback = delay, delay = 0);
		
		$.each(this, function(){
			_fade.call(this, (delay || 200)/10, 1);
		});	
	},
	fadeOut: function(delay, callback){
		var _fade = function(delay, degree){
			var ren = this;
			if(degree){
				ren.style.opacity = degree--/10;
				window.setTimeout(function(){		
					_fade.call(ren, delay, degree);
				},delay);
			}else{
				$(ren).hide();
				$.isFunc(callback) && callback.call(ren);
			}
		}
		
		$.isFunc(delay) && (callback = delay, delay = 0);
		
		$.each(this, function(){
			_fade.call(this, (delay || 200)/10, 10);
		});	
	},
	toggleFade: function(delay, callback){
		$.each(this, function(){
			if(this.style.display === "none"){
				$(this).fadeIn(delay, callback);
			}else{
				$(this).fadeOut(delay, callback);
			}
		});
	}	
});